package com.cw.carwashvehicles.controller;

import com.cw.carwashvehicles.domain.CustomerVehicles;
import com.cw.carwashvehicles.service.CustomerVehiclesService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/customerVehicles")

public class CustomerVehiclesController extends BaseController {
    @Autowired
    private CustomerVehiclesService customerVehiclesService;

    /**
     * 查询客户车辆信息列表
     * @param customerVehicles
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(CustomerVehicles customerVehicles) {
        startPage();
        List<CustomerVehicles> vehiclesList = customerVehiclesService.selectCustomerVehiclesList(customerVehicles);
        return getDataTable(vehiclesList);
    }

    /**
     * 查询客户车辆信息详情
     * @param id
     * @return
     */
    @GetMapping("/detail/{id}")
    public CustomerVehicles detail(@PathVariable(value = "id") Long id) {
        return customerVehiclesService.selectCustomerVehiclesById(id);
    }

    /**
     * 新增客户车辆信息
     * @param customerVehicles
     * @return
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody CustomerVehicles customerVehicles) {
        return toAjax(customerVehiclesService.insertCustomerVehicles(customerVehicles));
    }

    /**
     * 修改客户车辆信息
     * @param customerVehicles
     * @return
     */
    @PutMapping("/update")
    public AjaxResult update(@RequestBody CustomerVehicles customerVehicles) {
        return toAjax(customerVehiclesService.updateCustomerVehicles(customerVehicles));
    }

    /**
     * 删除客户车辆信息
     * @param id
     * @return
     */
    @DeleteMapping("/deleteById/{id}")
    public AjaxResult deleteById(@PathVariable Long id) {
        return toAjax(customerVehiclesService.deleteCustomerVehiclesById(id));
    }

    /**
     * 批量删除客户车辆信息
     * @param ids
     * @return
     */
    @DeleteMapping("/deleteByIds/{ids}")
    public AjaxResult deleteByIds(@PathVariable Long[] ids) {
        return toAjax(customerVehiclesService.deleteCustomerVehiclesByIds(ids));
    }
}
